import numpy as np
from audio_processing.base_processor import AudioProcessor


class OutputProcessor(AudioProcessor):
    """输出处理器（主要用于参数控制）"""

    def __init__(self, parameters):
        super().__init__(parameters)
        self.level = parameters.get('level', 1.0)

    def process(self, audio_data: np.ndarray) -> np.ndarray:
        """应用输出电平控制"""
        if not self.is_active:
            return audio_data

        # 确保数据形状正确
        audio_data = self._ensure_correct_shape(audio_data)

        return audio_data * self.level

    def update_parameters(self, new_parameters):
        super().update_parameters(new_parameters)
        self.level = new_parameters.get('level', self.level)